#ifndef DATABASEMANAGER_H
#define DATABASEMANAGER_H

#include <QObject>
#include <QtSql/QtSql>
#include <QtSql/QSqlDatabase>
#include <QDebug>

class databaseManager : public QObject
{

public:
    enum TypeSql {MYSQL, SQLITE};
    databaseManager(QObject *parent = 0);
    ~databaseManager();

    void Connect(QString host, QString user ,QString pass, QString dbName, TypeSql typeSql);

    bool OpenConnection();
    void CloseConnection();

    QSqlQuery RunQuery(const QString &sql);
    bool CreerTable(QString nomTable, QStringList NomChamp, QStringList typeData, QString foreignKey = "", QString references = "");
    QStringList ListeTable();
    void SupprimerTable(QString nomTable);

    static const QString TypeNull;
    static const QString TypePrimaryKey;

//    void InsertValue(QStringList value, QStringList champ, QString table);
//    void InsertValue(QString value, QString champ, QString table);

//    void RemoveValue(QString value, QString champ, QString table);
////    void RemoveValue(int id,  QString table, bool containsListe = false);
//    void RemoveValue(QStringList where,  QString table, bool containsListe = false);

////    void UpdateValue(QString set, QString table, QString where);
//    void UpdateValue(QString table, QString set, QStringList bindValues);

//    QStringList GetValue(QString champ, QString table);
//    QSqlQuery GetValueQuery(QStringList champs, QString table);

//    int GetId(QString table, QStringList SQLWhere);

//    static QString qMark(int count);


private:
    QSqlDatabase m_db;
    QString m_hostName;
    QString m_userName;
    QString m_password;
    QString m_databaseName;
    TypeSql m_TypeSql;
    QString m_typeId;

    bool m_connected;

};

#endif // DATABASEMANAGER_H
